#pragma once
#include <iostream>

#include "args.hxx"

struct CliArgs
{
    bool interactive{false};
    std::string macro;
    bool ok = true;  // 解析是否成功

    CliArgs(int argc, char** argv)
    {
        args::ArgumentParser parser{"Geant4 energy scanner", "."};
        args::HelpFlag help{parser, "help", "Display this help menu", {'h', "help"}};
        args::Flag interactiveFlag(parser, "interactive", "Enter Qt interactive mode", {'i', "interactive"});
        args::ValueFlag<std::string> macroFlag(parser, "FILE", "execute the input macro", {'f', "file"});

        try
        {
            parser.ParseCLI(argc, argv);
            interactive = (bool)interactiveFlag;
            if (macroFlag) macro = args::get(macroFlag);
        }
        catch (args::Help)
        {
            std::cout << parser;
            ok = false;
        }
        catch (args::ParseError& e)
        {
            std::cerr << e.what() << "\n" << parser;
            ok = false;
        }
    }
};